********Table 3 - Mexico********

eststo clear

*Load data
cd "$reploc/data/created_data"
use mex_full, clear

sort pid_link mxfls
drop if mxfls==.
*keep if panel==1

*Do this analysis for full sample
sort pid_link mxfls
foreach var of varlist rbuc_nga rbuc grbrprovAvg_lam0co3 grbrprovSD_lam0co3 inflation{
gen `var'dif=`var'-`var'[_n-1] if mxfls==3 & pid_link==pid_link[_n-1]
} 

gen eithrisk=0
replace eithrisk=1 if rbucdif!=. 

egen fullsample=total(eithrisk), by(pid_link)

keep if fullsample==1

keep if mxfls==3

*Attentiveness
gen badatt=.
replace badatt=1 if b3bne3>=3 & b3bne3!=.
replace badatt=0 if b3bne3<=2 & b3bne3!=.
egen badattmean=mean(badatt), by(pid_link)


label define ga 0 "Not GA" 1 "GA"

label values gambleaverse ga 

qui tabstat age woman totcogscore badatt mth_inc_ia, by(gambleaverse) stat(mean) save
qui tabstatmat B
matrix B = B'
matrix list B, f(%9.5g)

cd "$reploc/results"
esttab matrix(B) using Table3_Mexico.tex, replace
